import { apiSfctdPage } from '@/api/url/checkModule';
import { listReportingDataSearch } from '@/api/url/reportingWorks';
import router from '@/router';
import { isNullPm, isParam } from '@/utils/baseMethods';
import { reactive } from 'vue';

export default function importConfig() {
  const base = reactive({
    pagination: {
      defaultPageSize: 10,
      total: 100, //总条数
      current: 1,
      pageSize: 10,
      showTotal: true,
      showPageSize: true,
      pageSizeOptions: [10, 20, 30, 40, 50],
    },
    tabelList: null,
    checkFrom: {
      department: null,
      brevityCode: null,
      dispatchNumber: null,
      materialChargeNumber: null,
      operatorCode: null,
      operatorName: null,
      process: null,
      productName: null,
      productNo: null,
      supplierName: null,
      workOrder: null,
    },
  });

  const init = () => {
    getTable();
  };
  const getTable = () => {
    const steam = {
      size: base.pagination.pageSize,
      current: base.pagination.current,
    };
    Object.keys(base.checkFrom).map((res: any) => {
      if (!isNullPm(base.checkFrom[res])) {
        steam[res] = base.checkFrom[res];
      }
    });
    // listReportingDataSearch(steam).then((res: any) => {
    //     if (res.code === 200) {
    //         base.tabelList = res.data.records;
    //         base.pagination.total = res.data.total;
    //     }
    // });
    // base.tabelList = steamABC
    // base.pagination.total = 2
  };

  const columns = [
    {
      title: '审批名称',
      dataIndex: 'approval_process_name',
      align: 'center',
    },
    {
      title: '审批长度',
      dataIndex: 'approval_process_length',
      align: 'center',
    },
    {
      title: '创建时间',
      dataIndex: 'create_time',
      align: 'center',
    },
    {
      title: '修改时间',
      dataIndex: 'update_time',
      align: 'center',
    },
    {
      title: '备注',
      dataIndex: 'remark',
      align: 'center',
    },
    {
      title: '创建人',
      dataIndex: 'creator',
      align: 'center',
    },
    {
      title: '审批初始人员',
      dataIndex: 'creator',
      align: 'center',
    },
    {
      title: '审批终末人员',
      dataIndex: 'creator',
      align: 'center',
    },
    {
      title: '状态',
      dataIndex: 'state',
      align: 'center',
    },
  ];

  const handlePageChange = (page: number) => {
    base.pagination.current = page;
    init();
  };
  const handlePageSizeChange = (pageSize: number) => {
    base.pagination.pageSize = pageSize;
    init();
  };

  /**
   * @exports foundBoom 跳转到新增审批模块页面
   */
  const foundBoom = () => {
    router.push('auditFound');
  };

  return {
    columns,
    handlePageChange,
    handlePageSizeChange,
    base,
    init,
    foundBoom,
  };
}
